Find and Replace

Find and Replace allows you to find text in any open document and replace it with other text if you choose.  This feature is accessible from the Edit menu.  The Find/Replace command calls up the basic Find/Replace dialog box.  The Extended Find/Replace option calls up the Extended Find/Replace dialog box.  The Find Next option on the Edit menu repeats the last Find/Replace operation without calling the Find/Replace dialog box.

Both dialogs operate similarly however the Extended Find/Replace dialog allows for multi-line searches instead of single-line searches.

You can search for the string of text in the Find What text box.  You can choose whether to only search the Current Document or All Open Documents for the text.  You can choose whether to search forwards or backwards from the current cursor position.  Other options include Find Whole Word Only and Match Case. The Use Pattern Matching flag indicates whether you want to use regular expression searching specified in your Find What text.

The Replace button lets you replace any occurrences of the Find What text in your documents with the text in the Replace With text box.  Use the Replace All button to replace all occurrences of the text.

Pattern Matching

Pattern matching makes use of regular expressions to specify text by its characteristics rather than by its exact characters. A regular expression is composed of a sequence of sub-expressions. Each sub-expression must be in the form in the operators table displayed below. Entire expressions can be preceeded by a ^ character to indicate that the expression is only matched at the start of a line, or ended by a $ character to indicate that the expression can only exist at the end of a line.

Pattern matching examples:

Expression Matches Does Not Match
"one"|"two"oneONE
 twoTWO
\d(3)\.\d(2)123.4512.45
 001.231.23
[a-zA-Z]\w*Word2Words
"<!--".*"-->"<!-- Comment --><-- Not Comment -->

The following chart displays each operator that can be used when pattern matching:

Operators Description
a+ One or more occurrences of a
a* Zero or more occurences of a
a? Zero or one (i.e. optional) occurence of a
a{n} Exactly n occurences of a
a{n,} n or more occurences of a
a{,m} Zero or at most m occurences of a
a{n,m} At least n but not more than m occurences of a
a|b Either a or b
a||b a or b or both a and b in any order
abc a followed by b followed by c
[abc] A single character, one of a or b or c
[a-b] A single character, ranging in value from a to b inclusive
[^abc] A single character, any except a, b or c
(abc) a followed by b followed by c
"abc" The letters a followed by b followed by c with no special significance attached to a, b or c
. Any character except a newline
\a The letter a, with no special significance attached to a, special forms:
\t The tab character
\n The newline character
\r The return character
\f The formfeed character
\b The backspace character
\xNN The hex character NN
\0ooo The octal character ooo
\w A single character, one of [a-zA-Z0-9_]
\W Any single character not matching \w
\d A single character [0-9]
\D A single character not matching \d
\s A whitespace character [\t\r\n\f\b\ ]
\S A single character not matching \s

Excerpts of this document were taken from the TSMAx documentation, Copyright (c) 2000 dbRock Software.